package cn.rokhdelar.umbrsapi.core.utils;

import org.apache.commons.lang3.StringUtils;

public class EscapeUtil {
    //mysql的模糊查询时特殊字符转义  #$%&*-_+=;,?.!@~/\
    public static String escapeChar(String before){
        if(StringUtils.isNotEmpty(before)){
            before = before.replace("'", "\\'");
            before = before.replace("%", "\\%");
            before = before.replace("_", "\\_");
            before = before.replace("+", "\\+");
            before = before.replace(";", "\\;");
            before = before.replace(",", "\\,");
            before = before.replace("?", "\\?");
            before = before.replace("/", "\\/");
        }
        return before ;
    }

}
